//
//  HuXingViewController.m
//  LOU
//
//  Created by 要帅气的生活 on 15/11/10.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "HuXingViewController.h"
#import "Size.h"
#import "ToolUtil.h"
#import "CustomCell.h"
#import "HeaderView.h"
#import "XiangceViewController.h"
@interface HuXingViewController ()

@end

@implementation HuXingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden = YES;
    [ToolUtil createLine:margin_64 superView:self.view lift:0 width:WindowWidth hight:0.5 color:[UIColor grayColor]];
    [self createTitle:@"楼盘详情" midTitle:@"主力户型"];
    [self creatView];
    // Do any additional setup after loading the view.
}
- (void)creatView
{
    
    UICollectionViewFlowLayout *flowLayout= [[UICollectionViewFlowLayout alloc] init];
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;//滚动方向
    flowLayout.minimumLineSpacing = 10.0;//行间距(最小值)
//    flowLayout.headerReferenceSize = CGSizeMake(320, 100);

    flowLayout.minimumInteritemSpacing = 10.0;//item间距(最小值)
    flowLayout.itemSize = CGSizeMake((WindowWidth - 30)/2, 150);//item的大小
    flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);//设置section的边距
//    flowLayout.headerReferenceSize = CGSizeMake(320, 20);
//    flowLayout.footerReferenceSize = CGSizeMake(320, 20);
    UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 65, WindowWidth, WindowHeight - 65) collectionViewLayout:flowLayout];
    [collectionView registerClass:[CustomCell class] forCellWithReuseIdentifier:@"cellzhuli"];
//    [collectionView registerClass:[HeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"headerView"];
    
    collectionView.contentInset = UIEdgeInsetsMake(210, 0, 0, 0);
    collectionView.dataSource = self;
    collectionView.delegate = self;
    collectionView.backgroundColor = [UIColor grayColor];
    UIImageView  * aImageView = [[UIImageView alloc] initWithFrame:CGRectMake(margin_20, 0, (WindowWidth - margin_20 * 2), -180 )];
    aImageView.userInteractionEnabled = YES;
    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doTap)];
    [aImageView addGestureRecognizer:tap];
    aImageView.image = [UIImage imageNamed:@"shouye2.jpg"];
    
//    [collectionView registerClass:[HeadView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:headerIdentifier];
//    [collectionView registerClass:[FootView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:footerIdentifier];
    [collectionView addSubview:aImageView];
    [self.view addSubview:collectionView];
    
}
- (void)doTap
{
    [self presentViewController:[[XiangceViewController alloc] init] animated:YES completion:nil];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    
    return 4;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    [self presentViewController:[[XiangceViewController alloc] init] animated:YES completion:nil];
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 2;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
//    if (indexPath.section == 0) {
        static NSString * cellIdentifier = @"cellzhuli";
        CustomCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
//        if (cell == nil) {
//            cell = [[CustomCell alloc] initWithFrame:CGRectMake(0, 64, WindowWidth, 100)];
//        }
//        cell.backgroundColor = [UIColor yellowColor];
//        return cell;
//    }
//    static NSString * cellIdentifier = @"cellhuxing";
//    UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
////    if (cell==nil) {
////        cell = [[UICollectionViewCell alloc] initWithFrame:CGRectMake(0, 64, WindowWidth / 2, 100)];
////    }
//    cell.backgroundColor = DEBUG_CLOLR;
    return cell;
}
/*
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    //如果要显示的是一个区头视图
    if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
        //从重用队列中根据重用标示符和视图类型 取出一个区头视图
        //如果没有取到 内部会自动根据注册 的区头视图类型创建一个视图
        HeaderView * headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"headerView" forIndexPath:indexPath];
        headerView.backgroundColor = [UIColor cyanColor];
        headerView.aLabel.text = [NSString stringWithFormat:@"第%ld个分区",indexPath.section];
        return headerView;
    }
    return nil;
    
}*/

- (void)doBack:(UIButton *)btnBack
{
    
    [self.navigationController popViewControllerAnimated:YES];
    self.tabBarController.tabBar.hidden = YES;
}



@end
